with open("water.txt","r") as f:
    lines = f.readlines()
    print(lines)
# 将列表拼接成字符串
strs = ""
for line in lines:
    strs += line
print(strs)
# 拆分单词
words = strs.split()
print(words)
# 开始统计单词个数
obj = {}
for word in words:
    if word in obj:
        # 将计数加一
        obj[word] +=1
    else:
        obj[word] = 1
print(obj)
# 排序
print(dict(sorted(obj.items(),reverse=True,key=lambda x:x[1])))

with open("water.txt","r") as f:
    line = f.readline()
    while line!="":
        print(line)
        line = f.readline()

